import requests
from openpyxl.reader.excel import load_workbook

saveurl = ''


headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36',
    'Cookie':'JSESSIONID=4da18720-b0df-49d2-8453-9da842e7f52d; James_cookie_sYQDUGqqzHtheme=custom'
}

source_file_path = r'D:\Desktop\exceltest\特殊情况\云南滇中新区管理委员会.xlsx'
source_wb = load_workbook(source_file_path)
source_ws = source_wb['Sheet1']
source_num = 3
cell_A = source_ws[f'A{source_num}'].value
cell_B = source_ws[f'B{source_num}'].value
cell_C = source_ws[f'C{source_num}'].value
cell_D = source_ws[f'D{source_num}'].value
cell_E = source_ws[f'E{source_num}'].value
while cell_A is not None:
    param = {}
    param['csrf'] = 'c93a265b728b4bafb20f864b87ea6e39'
    param['organ_level'] = '3'
    param['parent_type'] = 'organ'
    param['type'] = '0'
    param['tyshxydm'] = cell_B
    param['code'] = cell_A
    param['short_code'] = cell_C
    param['name'] = cell_D
    param['short_name'] = cell_E
    param['organ_type'] = '9FB587BCDAA74286B7AD60567B26F79A'
    param['region_code'] = '530091'
    param['region_name'] = '滇中新区'
    param['parent_code'] = '1153020006984974XJ'
    param['path_parent_code'] = ''
    param['parent_name'] = '云南滇中新区管理委员会'
    param['sort_order'] = '1'
    param['leader'] = ''
    param['phone'] = ''
    param['email'] = ''
    param['zip_code'] = ''
    param['is_law'] = '0'
    param['is_hall'] = '0'
    param['is_monitor'] = '0'
    param['is_risk'] = '0'
    param['is_center'] = '0'
    param['win_num'] = '0'
    param['address'] = ''
    param['page_home'] = ''
    param['industry'] = '1'
    param['industry_name'] = '政府'
    param['gmorg_code'] = ''
    param['remark'] = ''
    response = requests.post(url=saveurl, headers=headers, data=param)
    print(response.text)
    source_num += 1
    cell_A = source_ws[f'A{source_num}'].value
    cell_B = source_ws[f'B{source_num}'].value
    cell_C = source_ws[f'C{source_num}'].value
    cell_D = source_ws[f'D{source_num}'].value
    cell_E = source_ws[f'E{source_num}'].value





